FROM postgres:12.7

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
RUN echo 'deb http://mirrors.163.com/debian/ buster main non-free contrib\n\
deb http://mirrors.163.com/debian/ buster-updates main non-free contrib\n\
deb http://mirrors.163.com/debian/ buster-backports main non-free contrib\n\
deb-src http://mirrors.163.com/debian/ buster main non-free contrib\n\
deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib\n\
deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib\n\
deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\n\
deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\n'\
>> /etc/apt/sources.list
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils ca-certificates wget \
&& apt-get install -y tar bzip2 make gcc
RUN apt-get install -y postgresql-server-dev-$PG_MAJOR
RUN mkdir build \
&& cd build \
&& wget -q -O - http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2 | tar xjf - \
&& cd scws-1.2.3 ; ./configure ; make install ; cd .. \
&& rm -rf scws-1.2.3
RUN wget -q -O - https://github.com/amutu/zhparser/archive/master.tar.gz | tar xzf - \
&& cd zhparser-master ; SCWS_HOME=/usr/local make && make install ; cd .. \
&& rm -rf zhparser-master
RUN apt-get purge -y --auto-remove ca-certificates wget postgresql-server-dev-$PG_MAJOR make gcc